/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.deptBudget.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.deptBudget.db.dao.FinBudgetAddDao;
import com.yunhoo.deptBudget.model.Budget;
import com.yunhoo.sys.db.util.DbTool;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class FinBudgetAddDaoImpl extends SqlMapDaoTemplate implements FinBudgetAddDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "finBudgetAdd.";

    public FinBudgetAddDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public SqlMapClient getSqlClient() {
        if (sqlmap == null) {
            sqlmap = DbTool.getSqlMapClient();
        }
        return sqlmap;
    }

    @Override
    public void deleteListById(List<Budget> paramli) throws SQLException {
        System.out.println(nameSpace + "deleteListById * n");
        sqlmap.startBatch();
        for (Budget param : paramli) {
            sqlmap.delete(nameSpace + "deleteListById", param);
        }
        sqlmap.executeBatch();
    }

    @Override
    public void updateListById(List<Budget> paramli) throws SQLException {
        System.out.println(nameSpace + "updateListById * n");
        sqlmap.startBatch();
        for (Budget param : paramli) {
            sqlmap.update(nameSpace + "updateListById", param);
        }
        sqlmap.executeBatch();
    }

    @Override
    public void insertList(List<Budget> paramli) throws SQLException {
        System.out.println(nameSpace + "insert * n");
        sqlmap.startBatch();
        for (Budget param : paramli) {
            sqlmap.insert(nameSpace + "insert", param);
        }
        sqlmap.executeBatch();
    }

    @Override
    public void insert(Budget param) throws SQLException {
        sqlmap.insert(nameSpace + "insert", param);
    }

    @Override
    public List<Budget> queryList(Budget param) throws SQLException {
        return sqlmap.queryForList(nameSpace + "queryList", param);
    }
}
